import request from '@/utils/request'

/**
 * 查询部门列表
 * @param params 查询参数
 */
export function getDepartmentList(params) {
  return request({
    url: '/department/list',
    method: 'get',
    params: params
  })
}

/**
 * 查询父级部门
 * @returns {*}
 */
export function getParentDepartment() {
  return request({
    url: '/department/getParentDepartment',
    method: 'get'
  })
}

/**
 * 添加部门（编辑部门），没有该部门编号时，进行新增，否则进行修改操作
 * @param data 部门信息
 * @returns {*}
 */
export function addDepartment(data) {
  return request({
    url: '/department/add',
    method: 'post',
    data: data
  })
}

/**
 * 删除部门
 * @param id 部门编号
 * @returns {*}
 */
export function deleteDepartment(id) {
  return request({
    url: '/department/delete/' + id,
    method: 'post'
  })
}

/**
 * 修改部门
 * @param data 部门信息
 * @returns {*}
 */
export function updateDepartment(data) {
  return request({
    url: '/department/update',
    method: 'post',
    data: data
  })
}

/**
 * 根据部门编号查询部门信息
 * @param id
 * @returns {*}
 */
export function getDepartmentById(id) {
  return request({
    url: '/department/get/' + id,
    method: 'post'
  })
}

export function checkDepartment(id) {
  return request({
    url: '/department/check/' + id,
    method: 'post'
  })
}

